#include "uiList.h"

#include <Poco/String.h>
#include <stdexcept>
#include <string>
#include "server/net/NetworkControl.h"
#include "misc/Interface.h"
/*********************************************************/
void uiList::execute()
{
	if ( parsed ) {
		// Get an instance of the network controller & interface
		NetworkControl& nc = NetworkControl::Instance();
		Interface& intf = Interface::Instance();

		std::string info = nc.getRingInformation();
		intf << info;
		intf.flush();
	}
}
/*********************************************************/
void uiList::parseOptions(std::vector<std::string>& arguments)
{
	Interface& intf = Interface::Instance();

	if ( arguments.size() != 0 ) {
		if ( arguments[0] == " ?" ) {
			helpInfo();
		} else if ( arguments[0] == "" ) {
			parsed = true;
		} else {
			intf << "Invalid usage of list, use list ? to get usage information" << std::endl;
			intf.flush();
		}
	}

	if ( arguments.size() == 0 ) {
		parsed = true;
	}
}
/*********************************************************/
void uiList::helpInfo()
{
	Interface& intf = Interface::Instance();

	// Print help information for the execute command
	intf << "list usage: list" << std::endl;
	intf << "list provides an overview of the current ring we are taking part of" << std::endl;
	intf.flush();
}
/*********************************************************/
